package com.shop.user.controller.user;

import com.modular.result.PageResult;
import com.modular.result.RspMessage;
import com.shop.user.service.user.IUserService;
import com.shop.user.vo.user.DataSttsReqVo;
import com.shop.user.vo.user.UserPageReq;
import com.shop.user.vo.user.UserPageResVo;
import com.shop.user.vo.user.UserReqVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/b/user")
@Api(tags = "用户模块")
public class UserController {
    @Autowired
    private IUserService userService;
    /**
     * 新增或修改用户信息
     * @param reqVo
     * @return
     */
    @ApiOperation("保存或修改用户信息")
    @PostMapping("saveOrUpdate")
    public RspMessage<Void> saveOrUpdate(@RequestBody UserReqVo reqVo){
        userService.saveOrUpdate(reqVo);
        return RspMessage.success();
    }

    /**
     * 修改用户的状态
     * @param reqVo
     * @return
     */
    @ApiOperation("修改用户状态")
    @PostMapping("modifyStts")
    public RspMessage<Void> modifyStts(@RequestBody DataSttsReqVo reqVo){
        userService.modifyStts(reqVo);
        return RspMessage.success();
    }

    /**
     * 查询分页
     * @param reqVo
     * @return
     */
    @ApiOperation("查询用户列表")
    @PostMapping("findPage")
    public RspMessage<PageResult<UserPageResVo>> findPage(@RequestBody  UserPageReq reqVo){
        return RspMessage.success(userService.findPage(reqVo));
    }
}
